$(function () {
    let price = parseInt($(".commodity-price").text())
    let freight = parseInt($(".freight").text())
    let discount = parseInt($(".out-pocket-amount").attr("discount"))
    let paymentAmount;
    if(discount===0){
        paymentAmount= price + freight;
    }else{
        paymentAmount = (price * (discount / 10)) + freight;
    }
    let result = paymentAmount.toFixed(2);
    $(".out-pocket-amount").text(result)

    $(".look-logistics").on("click", function () {
        const logisticsCompaniesName=$(this).attr("logistics-companies-name");
        const status=$(this).attr("status");
        const stationLongitude=$(this).attr("station-longitude");
        const stationLatitude=$(this).attr("station-latitude");
        const stationDeliveryman=$(this).attr("station-deliveryman");
        const stationProvince=$(this).attr("logistics-station-province");
        const stationCity=$(this).attr("logistics-station-city");
        const stationDistrict=$(this).attr("logistics-station-district");
        const stationName=$(this).attr("logistics-station-name");
        const warehouseName=$(this).attr("warehouse-name");
        const warehouseLatitude=$(this).attr("warehouse-latitude");
        const warehouseLongitude=$(this).attr("warehouse-longitude");
        const addressName=$(this).attr("address-name");
        const addressPhone=$(this).attr("address-phone");
        const addressProvince=$(this).attr("address-province");  
        const addressCity=$(this).attr("address-city");
        const addressDistrict=$(this).attr("address-district");
        const addressLatitude=$(this).attr("address-latitude");
        const addressLongitude=$(this).attr("address-longitude");
        const addressFullAddress=$(this).attr("address-full-address");
        window.location.href = "http://localhost:8083/www.xiaomi.com/background/map?" +
            "companiesName="+logisticsCompaniesName+"&ordersStatus=" +status+
            "&stationLongitude="+stationLongitude+"&stationLatitude="+stationLatitude+
            "&stationDeliveryman=" +stationDeliveryman+
            "&stationProvince="+stationProvince+"&stationCity="+stationCity +
            "&stationDistrict="+stationDistrict +
            "&stationName="+stationName +
            "&warehouseName="+warehouseName +
            "&warehouseLatitude="+warehouseLatitude+"&warehouseLongitude="+warehouseLongitude+
            "&addressName="+addressName +
            "&addressPhone="+addressPhone+"&addressProvince=" +addressProvince+
            "&addressCity="+addressCity+"&addressDistrict=" +addressDistrict+
            "&addressLatitude="+addressLatitude+"&addressLongitude="+addressLongitude +
            "&addressFullAddress="+addressFullAddress;
    })
})